package main;

import java.util.LinkedList;

import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;

import app.model.UserDaoImpl;
import app.model.UserEntity;
import app.view.SearchForm;
import app.view.UserPage;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				LinkedList<UserEntity> users = UserDaoImpl.getInstance().getAllUsers();
				int size = users.size();
				String[] opcoes = new String[size];
				int counter = 0;
				for (UserEntity it : users) {
					opcoes[counter] = it.getEmail(); 
					if(counter < size){
						counter++;
					}
				}

				JList<String> list = new JList<String>(opcoes);
				list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
				list.setSelectedIndex(0);
				JOptionPane.showMessageDialog(
						null, list, "Selecione um utilizador", JOptionPane.PLAIN_MESSAGE);
				  
				
				Boolean[] opcoes2 = new Boolean[] {true, false};
				JList<Boolean> list2 = new JList<Boolean>(opcoes2);
				list2.setSelectedIndex(0);
				list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
				
				JOptionPane.showMessageDialog(
						null, list2, "E admin?", JOptionPane.PLAIN_MESSAGE);
				
				
				new SearchForm().showSearchForm(list.getSelectedValue(), list2.getSelectedValue());
				//new UserPage().showUserProfile("teste");
				//UserDaoImpl.getInstance().insertUser(new UserEntity("something", "lala", "lala", "lala"));
				
			}
			
		});

	}

}
